//
//  MyTaskViewController.m
//  share_business
//
//  Created by baidufz on 2017/9/19.
//  Copyright © 2017年 wyl. All rights reserved.
//

#import "MyTaskViewController.h"
#import "UICollectionView+RegisterCell.h"
#import "MyTaskHeaderCell.h"
#import "MyTaskItem1Cell.h"
#import "MyTaskItemCell.h"
#import "MyTaskMenuView.h"


@interface MyTaskViewController () <UITableViewDataSource, UITableViewDelegate>

@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation MyTaskViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self registerCells];
    [self initMyTask];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.navigationItem.title = @"我的任务";
    [self defaultMessageRightButton];
    
}

- (void)registerCells {
    [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([MyTaskHeaderCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([MyTaskHeaderCell class])];
     [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([MyTaskItemCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([MyTaskItemCell class])];
}

- (void)initMyTask {
    _tableView.dataSource = self;
    _tableView.delegate = self;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 1) {
        return 10;
    }
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        MyTaskHeaderCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MyTaskHeaderCell class]) forIndexPath:indexPath];
        return cell;
    }
    MyTaskItemCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MyTaskItemCell class]) forIndexPath:indexPath];
    return cell;
}

- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    
    if (section == 1) {
        MyTaskMenuView *view = [[MyTaskMenuView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];

        return view;
    }
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 0) {
        return 180;
    }
    return 120;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 1) {
        return 60;
    }
    return 0;
}

- (IBAction)obtainCharm:(id)sender {
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
